<form role="form" name="htmlForm">
  <div class="container" ng-show="dataReady">
    <div class="formheader">
      <h3 class="">Nuevo estudio</h3>
      *Campos obligatorios
    </div>
    <div class="form-group">
      <label for="selectedPatient" class="col-sm-3 control-label">Paciente:</label>
      <div class="col-sm-7 scp-row" ><input type="text" class="form-control" id="selectedPatient" ng-model="selectedPatient" 
        typeahead="patient as patient.name for patient in getPatients($viewValue) | limitTo:10"
        typeahead-min-length="2"
        typeahead-editable="true"
        ng-blur="checkForPatient();"
        typeahead-on-select='onPatientSelected($item, $model, $label)'
        required/></div>
        <label for="formObject.patient_age" class="col-sm-1 control-label">Edad:</label>
        <div class="col-sm-1 scp-row" ><input type="text" class="form-control" id="formObject.patient_age" ng-model="formObject.patient_age" ng-maxlength="3" ng-blur="updatePatientAge()"></div>
    </div>
    <div class="form-group ">
      <label for="selectedDoctor" class="col-sm-3 control-label ">Doctor:</label>
       <div class="col-sm-9 scp-row"><input type="text" class="form-control" id="selectedDoctor" ng-model="selectedDoctor" 
        typeahead="doctor as doctor.name for doctor in getDoctors($viewValue) | limitTo:10"
        typeahead-min-length="2"
        typeahead-editable="true"
        ng-blur="checkForDoctor();"
        required/></div>
    </div>
    <div class="form-group ">
      <label for="formObject.type" class="col-sm-3">Estudio:</label>
      <div class="col-sm-9 scp-row">
        <select class="form-control" id="formObject.type" ng-model="formObject.type">
          <option value="">Seleccione estudio</option>
          <option value="1">Citología</option>
          <option value="2">Androscopía</option>
          <option value="4">Colposcopía</option>
          <option value="8">Histeroscopía</option>
          <option value="16">Histopatología</option>
          <option value="32">Especiales</option>
        </select>
      </div>
    </div>
    <div class="form-group ">
      <label for="formObject.main_doctor_id" class="col-sm-3">Dr. a cargo:</label>
      <div class="col-sm-9 scp-row">
        <select class="form-control" id="formObject.main_doctor_id" ng-model="formObject.main_doctor_id" 
        ng-options="value.id as value.name for value in owners"
        required>
        </select>
      </div>
    </div>
    <div class="form-group"> 
      <label for="formObject.key_prefix" class="col-sm-3">Clave de estudio:</label> 
      <div class="col-sm-1 scp-row">
        <input type="text" class="form-control text-uppercase" id="formObject.key_prefix" reg-exp-require="/^[a-zA-Z]{1,3}$/" ng-model="formObject.key_prefix" ng-maxlength="3" ng-blur="getNextKeyNumber()" required></input>
      </div>      
      <label class="col-sm-1 btn btn-default scp-row glyphicon glyphicon-refresh" ng-click="getNextKeyNumber()"></label> 
      <div class="col-sm-7 scp-row">
        <input type="text" class="form-control" id="formObject.key_number" ng-model="formObject.key_number" ng-maxlength="6" ng-disabled="waitForSave" required></input>
      </div> 
    </div>
    <div class="form-group ">
      <label for="formObject.notes" class="col-sm-3">Anotaciones:</label>
      <div class="col-sm-9 scp-row"><textarea class="form-control notesBox" id="formObject.notes" ng-model="formObject.notes"></textarea></div>
    </div>
    <div class="form-group text-right">
        <div class="col-sm-12 scp-row">
          <button class="btn btn-default" ng-click="reset()" ng-show="formObject && formObject.id" ng-disabled="waitForSave"><span class="glyphicon glyphicon-repeat"></span>&nbsp;Restablecer</button>
          <button class="btn btn-default" ng-click="save(formObject)" ng-disabled="waitForSave"><span class="glyphicon glyphicon-floppy-disk"></span>&nbsp;Guardar</button></div>
      </div>
    </div>
</form>
